/***************************************************************************
 *   Copyleft 2006-2007 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>			                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#include <windows.h>
#include "./resource.h"
#include "./Types/Types.h"
#include "./Macros/Macros.h"
#include "./Window/MainWindow.h"

#include "./Memtracer/MemoryTracker.h"
START_MEMORY_TRACKING_SYSTEM

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, cInt iShowCmd) {
	LOGS_OPEN;
    MainWindow window(hInstance);
	LOGS.Info("Application started");

    MSG msg;

    ZeroMemory(&msg, sizeof(msg));
    HACCEL hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));

    while (msg.message != WM_QUIT) {
        if (PeekMessage(&msg, cNull, 0U, 0U, PM_REMOVE)) {
            if (!TranslateAccelerator(msg.hwnd, hAccel, &msg) && !IsDialogMessage(msg.hwnd, &msg)) {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
		} else {
			window.Render();
		}
    }
	LOGS.Info("Closing application");
	LOGS_CLOSE;
	STOP_MEMORY_TRACKING_SYSTEM;

    return (cInt) msg.wParam;
}

